package com.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SqlSessionTools {
	
	public static SqlSession getSqlSession() {
		InputStream in;
		SqlSessionFactory factory;
		SqlSession session = null;
		
		try {
			in = Resources.getResourceAsStream("spring/spring-mybatis.xml");
			factory = new SqlSessionFactoryBuilder().build(in);
			session = factory.openSession();
			session.commit(true);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return session;
		
	}

}
